// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()

const db = cloud.database()
const _ = db.command
// 云函数入口函数
exports.main = async (event, context) => {
    if (event.type == 1) {
        return await db.collection('user').where({
            openid: event.openid
        }).update({
            data: {
                name: event.name,
                idcardnum: event.idcardnum,
                phonenum: event.phonenum,
                sex: event.sex,
                wordid: ''
            }
        })
    }
    else if(event.type==2){
        return await db.collection('user2').where({
            openid: event.openid
        }).update({
            data: {
                name: event.name,
                idcardnum: event.idcardnum,
                phonenum: event.phonenum,
                sex: event.sex,
                wordid: ''
            }
        })
    }
    else if(event.type==3){
        return await db.collection('user3').where({
            openid: event.openid
        }).update({
            data: {
                name: event.name,
                idcardnum: event.idcardnum,
                phonenum: event.phonenum,
                sex: event.sex,
                wordid: ''
            }
        })
    }
}